﻿namespace MicroCloud.Utils
{
    /// <summary>
    /// 自定义Decimal类型的精度属性
    /// <para>6.0 后加入 PrecisionAttribute，效果一样：[Precision(precision: 10, scale: 2)]</para>
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
    public class DecimalPrecisionAttribute : Attribute
    {
        #region 构造函数
        /// <summary>
        /// 初始化一个自定义Decimal类型的精度属性 <see cref="DecimalPrecisionAttribute"/> 的新实例
        /// </summary>
        public DecimalPrecisionAttribute()
            : this(22, 10)
        { }

        /// <summary>
        /// 初始化一个自定义Decimal类型的精度属性 <see cref="DecimalPrecisionAttribute"/> 的新实例
        /// </summary>
        /// <param name="precision">精度</param>
        /// <param name="scale">刻度(保留位数)</param>
        public DecimalPrecisionAttribute(byte precision = 22, byte scale = 10)
        {
            Precision = precision;
            Scale = scale;
        }

        #endregion

        #region 属性
        /// <summary>
        /// 精度
        /// </summary>
        public int Precision { get; set; } = 22;

        /// <summary>
        /// 刻度(保留位数)
        /// </summary>
        public int Scale { get; set; } = 10;

        #endregion

    }
}